package com.x.attendance.core.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import com.x.base.core.entity.annotation.*;
import org.apache.openjpa.persistence.jdbc.Index;

import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.SliceJpaObject;
import com.x.base.core.project.annotation.FieldDescribe;

/**
 * 员工信息实体类
 * @author Manus AI
 */
@ContainerEntity
@Entity
@Table(name = PersistenceProperties.Employee.table, uniqueConstraints = {
		@UniqueConstraint(name = PersistenceProperties.Employee.table + JpaObject.IndexNameMiddle
				+ JpaObject.DefaultUniqueConstraintSuffix, columnNames = { JpaObject.IDCOLUMN,
						JpaObject.CREATETIMECOLUMN, JpaObject.UPDATETIMECOLUMN, JpaObject.SEQUENCECOLUMN }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Employee extends SliceJpaObject {

	private static final long serialVersionUID = 1325197931747463979L;
	private static final String TABLE = PersistenceProperties.Employee.table;

	@Override
	public String getId() {
		return id;
	}

	@Override
	public void setId(String id) {
		this.id = id;
	}

	@FieldDescribe("数据库主键,自动生成.")
	@Id
	@Column(length = length_id, name = ColumnNamePrefix + id_FIELDNAME)
	private String id = createId();

	@Override
	public void onPersist() {
	}

	/*
	 * =============================================================================
	 * ===== 以下为员工信息字段
	 * =============================================================================
	 */

	public static final String employeeId_FIELDNAME = "employeeId";
	@FieldDescribe("员工工号")
	@Index(name = TABLE + IndexNameMiddle + employeeId_FIELDNAME)
	@Column(length = length_255B, name = ColumnNamePrefix + employeeId_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private String employeeId;

	public static final String name_FIELDNAME = "name";
	@FieldDescribe("员工姓名")
	@Index(name = TABLE + IndexNameMiddle + name_FIELDNAME)
	@Column(length = length_255B, name = ColumnNamePrefix + name_FIELDNAME)
	@CheckPersist(allowEmpty = false)
	private String name;

	public static final String department_FIELDNAME = "department";
	@FieldDescribe("部门")
	@Column(length = length_255B, name = ColumnNamePrefix + department_FIELDNAME)
	private String department;

	public static final String position_FIELDNAME = "position";
	@FieldDescribe("职位")
	@Column(length = length_255B, name = ColumnNamePrefix + position_FIELDNAME)
	private String position;

	public static final String phone_FIELDNAME = "phone";
	@FieldDescribe("电话号码")
	@Column(length = 50, name = ColumnNamePrefix + phone_FIELDNAME)
	private String phone;

	public static final String enabled_FIELDNAME = "enabled";
	@FieldDescribe("是否启用")
	@Column(name = ColumnNamePrefix + enabled_FIELDNAME)
	private Boolean enabled;

	public static final String o2oaPersonId_FIELDNAME = "o2oaPersonId";
	@FieldDescribe("O2OA人员ID")
	@Index(name = TABLE + IndexNameMiddle + o2oaPersonId_FIELDNAME)
	@Column(length = length_id, name = ColumnNamePrefix + o2oaPersonId_FIELDNAME)
	private String o2oaPersonId;

	// Getters and Setters
	public String getEmployeeId() {
		return employeeId;
	}

	public void setEmployeeId(String employeeId) {
		this.employeeId = employeeId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public String getO2oaPersonId() {
		return o2oaPersonId;
	}

	public void setO2oaPersonId(String o2oaPersonId) {
		this.o2oaPersonId = o2oaPersonId;
	}
}

